package fhp.hlhj.giantfold.adapter
import android.app.Activity
import android.support.v7.widget.GridLayoutManager
import android.widget.GridLayout
import android.widget.ImageView
import android.widget.RelativeLayout
import android.widget.TextView
import com.alibaba.baichuan.android.trade.AlibcTrade
import com.alibaba.baichuan.android.trade.callback.AlibcTradeCallback
import com.alibaba.baichuan.android.trade.model.AlibcShowParams
import com.alibaba.baichuan.android.trade.model.OpenType
import com.alibaba.baichuan.android.trade.page.AlibcDetailPage
import com.alibaba.baichuan.trade.biz.context.AlibcTradeResult
import com.bumptech.glide.Glide
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import fhp.hlhj.giantfold.R
import fhp.hlhj.giantfold.javaBean.GoodListBean
import fhp.hlhj.giantfold.utils.LogUtil
/**
 * author: FHP
 * data: on 2018\1\16 0016 13:58
 * E-Mail: 103945089@qq.com
 */
class MallAapter(layoutResId: Int, data: ArrayList<GoodListBean.DataBean>) : BaseQuickAdapter<GoodListBean.DataBean, BaseViewHolder>(layoutResId,data ) {
    override fun convert(helper: BaseViewHolder, item: GoodListBean.DataBean) {
        helper.setText(R.id.itemTitle,item.name)
        helper.setText(R.id.itemPrice,item.price)
        helper.setText(R.id.itemOldPrice,item.old_price)
        val itemPrice = helper.getView<TextView>(R.id.itemPrice)
        val imgIcon = helper.getView<ImageView>(R.id.itemImg)
        Glide.with(mContext).load(item.pict_url).asBitmap().into(imgIcon)
        val params = helper.itemView.layoutParams as GridLayoutManager.LayoutParams
        if (helper.position/2==0){
            params.setMargins(30,0,0,0)
        }else{
            params.setMargins(0,0,30,0)
        }
        helper.itemView.layoutParams=params
    }

}